package org.com.Controller;

import Entity.OrderVoucher;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.com.Service.IOrderVoucherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderVoucherController {
    @Autowired
    private IOrderVoucherService orderVoucherService;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("/show")
    public List<OrderVoucher> show() {
        String user = stringRedisTemplate.opsForValue().get("login:user:");

        LambdaQueryWrapper<OrderVoucher> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(OrderVoucher::getUserId, user);
        return orderVoucherService.list(wrapper);

    }

}
